package io.github.lee.repository.jel.dao

import android.content.Context
import androidx.room.Room
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.android.qualifiers.ApplicationContext
import dagger.hilt.components.SingletonComponent


@Module
@InstallIn(SingletonComponent::class)
object SessionDatabaseModel {
    @Provides
    fun provideSessionDatabase(@ApplicationContext context: Context): SessionDatabase =
        Room.databaseBuilder(
            context,
            SessionDatabase::class.java,
            "${context.packageName}.session.db"
        )
            .allowMainThreadQueries()
            .build()

    @Provides
    fun provideSessionDao(database: SessionDatabase): SessionDao =
        database.sessionDao()

}